﻿<!DOCTYPE>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	//获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("basePath", basePath);
	pageContext.setAttribute("path", path);
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="${basePath}css/style.css" />
<script type="text/javascript" src="${basePath}js/jquery-3.2.1.js"></script>
<title>公司信息</title>
<meta content="description" name="description">
<meta content="keywords" name="keywords">
</head>
<body>
	<div id="body">
		<%@include file="../header.jsp"%>
		<!-- end #header -->
		
		<div id="container">
			<%@include file="../left.jsp"%>
			<!-- end .sidebar -->
			<div class="content">
				<dl class="company_center_content">
					<dt>
						<h1>
							<em></em> 已下线职位 
						</h1>
					</dt>
					<dd>
						<form id="searchForm">
							<input type="hidden" value="Publish" name="type">
							<ul class="reset my_jobs" id="dataUl">
							</ul>
						</form>
					</dd>
				</dl>
			</div>
			<!-- end .content -->
		</div>
		<!-- end #container -->
	</div>
	<!-- end #body -->
	
<script type="text/javascript">
	$(function() {
		console.log("document ready and console log this .");
		getPosition();
	});

function getPosition(){
	$.ajax({
		type : 'POST',
		data : {
			status : "off"
		},
		url : '${basePath}hr/getPositions',
		dataType : 'json',
		success : function(result) {
			console.log("success");
			var model = result.model;
			if (model.code == 0) {
				console.log(model.msg);
				var list = model.list;
				$("#dataUl").html("");
				if(list.length == 0){
					$("#dataUl").append('<div class="addnew">没有已下线职位……<br></div>');
					
				}
				for(var i=0; i<list.length; i++){
					var tem = "";
					tem += '<li ><h3><a target="_blank" title="'+list[i].positionDesc+'" href="javascript:validate('+list[i].riId+');">'+list[i].positionDesc+'</a> <span>['+list[i].workCity+']</span>';
					tem += '</h3><div>'+list[i].salaryMin+'k-'+list[i].salaryMax+'k / '+list[i].demandExpDesc+' / '+list[i].educationalBackgroundDesc+'</div><div class="c9">发布时间： '+new Date(list[i].publishTime).toLocaleDateString()+'</div>';
					tem += '<div class="links"><a target="_blank" class="job_edit" href="${basePath}hr/positionWriter/'+list[i].riId+'">编辑</a>';
					tem += '<a class="job_offline" href="javascript:pon(\''+list[i].riId+'\');">上线</a></div></li>';
					$("#dataUl").append(tem);
				}
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		}
	});
}

function pon(id){
	$.ajax({
		type : 'POST',
		data : {
			id : id
		},
		url : '${basePath}hr/positionOn',
		dataType : 'json',
		success : function(result) {
			console.log("success");
			var model = result.model;
			if (model.code == 0) {
				console.log(model.msg);
				alert(model.msg);
				getPosition();//重新载入数据
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		}
	});
}
	
	
</script>

	
</body>
</html>